package com.internetCafes.spms.web.sys.model;

import com.internetCafes.spms.common.CommonConstants;
import com.internetCafes.spms.core.validator.group.AddGroup;
import com.internetCafes.spms.core.validator.group.UpdateGroup;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 系统用户
 * 
 * @author Sunny
 * @email rekeeper2011@hotmail.com
 * @date 2016年9月18日 上午9:28:55
 */
@Accessors(chain = true)
public class UserInfo implements Serializable {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 用户ID
	 */
	private Long id;

	/**
	 * 用户名
	 */
	@NotBlank(message="用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
	private String name;


	/**
	 * 用户名
	 */
	@NotBlank(message="显示名不能为空", groups = {AddGroup.class, UpdateGroup.class})
	private String nickName;


	/**
	 * 密码
	 */
	@NotBlank(message="密码不能为空", groups = AddGroup.class)
	private String password;

	/**
	 * 盐
	 */
	private String salt;

	/**
	 * 邮箱
	 */
	@NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
	private String email;

	/**
	 * 手机号
	 */
	private String mobile;

	/**
	 * 状态  0：禁用   1：正常
	 */
	private Integer status;
	
	/**
	 * 角色ID列表
	 */
	private List<Long> roleIdList = new ArrayList<>();
	
	/**
	 * 创建者ID
	 */
	private Long createUserId;

	/**
	 * 创建时间
	 */
	private Date createTime;

	/**
	 * 部门ID
	 */
	//@NotNull(message="部门不能为空", groups = {AddGroup.class, UpdateGroup.class})
	private Long deptId;

	/**
	 * 部门名称
	 */
	private String deptName;

	/**
	 * 用户类型
	 */
	private int type;

	/**
	 * 具体用户Id
	 */
	private Long userId;

	/**
	 * 微信小程序openId
	 */
	private String openId;

	/**
	 * 管理层标签 0-默认 1-管理层
	 */
	private Integer managerFlag;

	/**
	 * 角色类型标签 1-平台角色：包括admin和企业管理员 能看到企业所有客户信息|2-企业角色：企业自己创建的角色，进行权限分配用
	 */
	private Integer roleTypeId;

	/**
	 * 区域管理员标签 0-否 1-是
	 */
	private Integer areaManagerFlag;

	/**
	 * 所属企业部门id
	 */
	private Long tenantDeptId;

	/**
	 * 颜色编码
	 */
	private String colorCode;

	private Long tenantId;

	public UserInfo(){}
	public UserInfo(Long id, String nickName){
		this.id = id;
		this.nickName = nickName;
	}

	public UserInfo(String name, String nickName, String password, String mobile, Long deptId, String deptName, int type, Long userId) {
		this.name = name;
		this.nickName = nickName;
		this.password = password;
		this.mobile = mobile;
		this.deptId = deptId;
		this.deptName = deptName;
		this.type = type;
		this.userId = userId;
		this.createTime = new Date();
	}

	public Integer getAreaManagerFlag() {
		return areaManagerFlag;
	}

	public void setAreaManagerFlag(Integer areaManagerFlag) {
		this.areaManagerFlag = areaManagerFlag;
	}

	public Long getTenantId() {
		return tenantId;
	}

	public void setTenantId(Long tenantId) {
		this.tenantId = tenantId;
	}

	public String getColorCode() {
		return colorCode;
	}

	public void setColorCode(String colorCode) {
		this.colorCode = colorCode;
	}

	public Integer getRoleTypeId() {
		return roleTypeId;
	}

	public void setRoleTypeId(Integer roleTypeId) {
		this.roleTypeId = roleTypeId;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	/**
	 * 设置：密码
	 * @param password 密码
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * 获取：密码
	 * @return String
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * 设置：邮箱
	 * @param email 邮箱
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * 获取：邮箱
	 * @return String
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * 设置：手机号
	 * @param mobile 手机号
	 */
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	/**
	 * 获取：手机号
	 * @return String
	 */
	public String getMobile() {
		return mobile;
	}

	/**
	 * 设置：状态  0：禁用   1：正常
	 * @param status 状态  0：禁用   1：正常
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	/**
	 * 获取：状态  0：禁用   1：正常
	 * @return Integer
	 */
	public Integer getStatus() {
		return status;
	}

	/**
	 * 设置：创建时间
	 * @param createTime 创建时间
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	/**
	 * 获取：创建时间
	 * @return Date
	 */
	public Date getCreateTime() {
		return createTime;
	}

	public List<Long> getRoleIdList() {
		return roleIdList;
	}

	public void setRoleIdList(List<Long> roleIdList) {
		this.roleIdList = roleIdList;
	}

	public Long getCreateUserId() {
		return createUserId;
	}

	public void setCreateUserId(Long createUserId) {
		this.createUserId = createUserId;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public Long getDeptId() {
		return deptId;
	}

	public void setDeptId(Long deptId) {
		this.deptId = deptId;
	}

	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

	public String getTypeDescr(){
		return CommonConstants.UserInfoType.getDescr(type);
	}

	public Integer getManagerFlag() {
		return managerFlag;
	}

	public void setManagerFlag(Integer managerFlag) {
		this.managerFlag = managerFlag;
	}

	public Long getTenantDeptId() {
		return tenantDeptId;
	}

	public void setTenantDeptId(Long tenantDeptId) {
		this.tenantDeptId = tenantDeptId;
	}
}
